package com.ssm.module.user.service;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ssm.common.service.CrudService;
import com.ssm.module.user.dao.UserDao;
import com.ssm.module.user.entity.User;
@Service
public class UserService extends CrudService<UserDao, User> {
	@Autowired
	private UserDao userMapper;
	
	public String checkUser(User user,HttpSession session) throws Exception {
		User u = userMapper.findUserByName(user.getUsername());
		if (u != null) {
			if (u.getPassword().equals(user.getPassword())) {
				session.setAttribute("user", u);
				return "101";	//用户登录成功
			} else {
				return "102";	//用户登录失败
			}
		} else {
			return "102";	//用户登录失败
		}
	}

}
